package com.dsz.Ui;


import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;  //grid layout
import java.awt.event.ActionEvent; // actionevent的包
import java.awt.event.ActionListener;//actionlistener 的包

// 主类
public class FirstPage extends JFrame {
    private DefaultTableModel tableModel;

    private int currentId = 1;

    public void StudentManager() {
        setTitle("Student Manager");
        setSize(800, 600);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);



        tableModel = new DefaultTableModel(new String[]{"ID", "Name", "Age", "Sex", "Class Name"}, 0);


        // 创建表格
        JTable table = new JTable(tableModel);
        JScrollPane scrollPane = new JScrollPane(table);
        add(scrollPane, BorderLayout.CENTER);

        // 创建按钮面板
        JPanel buttonPanel = new JPanel();
        add(buttonPanel, BorderLayout.SOUTH);

        // 添加按钮
        JButton addButton = new JButton("Add");
        JButton deleteButton = new JButton("Delete");
        JButton updateButton = new JButton("Update");
        JButton searchButton = new JButton("Search");

        buttonPanel.add(addButton);
        buttonPanel.add(deleteButton);
        buttonPanel.add(updateButton);
        buttonPanel.add(searchButton);

        // 按钮事件监听器
        addButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });

        deleteButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
            //重写了方法
            }
        });

        updateButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });

        searchButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                searchStudent();
            }
        });
    }







    // 搜索学生（这里只是简单地弹出一条消息，实际应用中应该实现搜索功能）
    private void searchStudent() {
        // 这里应该弹出一个对话框让用户输入搜索条件，但为了简化，直接显示一条消息
        JOptionPane.showMessageDialog(this, "Search functionality not implemented.");
    }



}


